import 'dart:convert';
import 'dart:ffi';

import 'package:yuan_hang_app/widget/label_item.dart';

class ExteriorEntity {
  int id;
  int modelId;
  String exterior;
  String exteriorName;
  String carHub;
  double? price;

  ExteriorEntity({
    required this.id,
    required this.modelId,
    required this.exterior,
    required this.exteriorName,
    required this.carHub,
    required this.price,
  });

  factory ExteriorEntity.fromJson(Map<String, dynamic> json) => ExteriorEntity(
        id: json["id"],
        modelId: json["modelId"],
        exterior: json["exterior"],
        exteriorName: json["exteriorName"],
        carHub: json["carHub"],
        price: json["price"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "modelId": modelId,
        "exterior": exterior,
        "exteriorName": exteriorName,
        "carHub": carHub,
        "price": price,
      };

  ExteriorEntity exteriorEntityFromJson(String str) =>
      ExteriorEntity.fromJson(json.decode(str));

  String exteriorEntityToJson(ExteriorEntity data) =>
      json.encode(data.toJson());

  static List<Map> exchangeLabelList(List<ExteriorEntity> entitys) {
    List<Map> list = [];
    for (ExteriorEntity entity in entitys) {
      list.add({
        "label": entity.exteriorName,
        "value": entity.exterior,
        "id": entity.id
      });
    }
    return list;
  }
}
